package model.commands.booleans;

import java.util.List;
import model.Environment;
import model.SyntaxErrorException;
import model.commands.Command;


/**
 * Name:
 * NOTEQUAL? value1 value2
 * NOTEQUALP value1 value2
 * 
 * Description:
 * returns 1 if value1 and value2 are not equal, otherwise 0
 * 
 * @author JLongley
 * @author Erick Gonzalez
 */
public class NotEqualCommand extends Command {

    @Override
    public int evaluate(Environment e) throws SyntaxErrorException {
        List<Command> myArguments = getArguments();
        //evaluates to true if any of the arguments don't equal the first argument
        boolean myNotEqual = false;
        int firstArg = myArguments.get(0).evaluate(e);
        for (int i = 1; i < myArguments.size(); i++) {
            myNotEqual = myNotEqual || firstArg != myArguments.get(i).evaluate(e);
        }        
        return myNotEqual ? 1 : 0;
    }
}
